﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a stereo model.</summary>
	// Token: 0x02000065 RID: 101
	public class HStereoModel : HHandle
	{
		// Token: 0x06001839 RID: 6201 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HStereoModel() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x0600183A RID: 6202 RVA: 0x0009B5CE File Offset: 0x000997CE
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HStereoModel(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x0600183B RID: 6203 RVA: 0x0009B5DD File Offset: 0x000997DD
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HStereoModel(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x0600183C RID: 6204 RVA: 0x0009B5EC File Offset: 0x000997EC
		private void AssertSemType()
		{
			base.AssertSemType("stereo_model");
		}

		// Token: 0x0600183D RID: 6205 RVA: 0x0009B5F9 File Offset: 0x000997F9
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HStereoModel obj)
		{
			obj = new HStereoModel(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x0600183E RID: 6206 RVA: 0x0009B614 File Offset: 0x00099814
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HStereoModel[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HStereoModel[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HStereoModel(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Create a HALCON stereo model.
		///   Modified instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="cameraSetupModelID">Handle to the camera setup model.</param>
		/// <param name="method">Reconstruction method. Default: "surface_pairwise"</param>
		/// <param name="genParamName">Name of the model parameter to be set. Default: []</param>
		/// <param name="genParamValue">Value of the model parameter to be set. Default: []</param>
		// Token: 0x0600183F RID: 6207 RVA: 0x0009B684 File Offset: 0x00099884
		public HStereoModel(HCameraSetupModel cameraSetupModelID, string method, HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(527);
			HalconAPI.Store(proc, 0, cameraSetupModelID);
			HalconAPI.StoreS(proc, 1, method);
			HalconAPI.Store(proc, 2, genParamName);
			HalconAPI.Store(proc, 3, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(cameraSetupModelID);
		}

		/// <summary>
		///   Create a HALCON stereo model.
		///   Modified instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="cameraSetupModelID">Handle to the camera setup model.</param>
		/// <param name="method">Reconstruction method. Default: "surface_pairwise"</param>
		/// <param name="genParamName">Name of the model parameter to be set. Default: []</param>
		/// <param name="genParamValue">Value of the model parameter to be set. Default: []</param>
		// Token: 0x06001840 RID: 6208 RVA: 0x0009B6FC File Offset: 0x000998FC
		public HStereoModel(HCameraSetupModel cameraSetupModelID, string method, string genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(527);
			HalconAPI.Store(proc, 0, cameraSetupModelID);
			HalconAPI.StoreS(proc, 1, method);
			HalconAPI.StoreS(proc, 2, genParamName);
			HalconAPI.Store(proc, 3, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(cameraSetupModelID);
		}

		/// <summary>
		///   Free the memory of a stereo model.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		// Token: 0x06001841 RID: 6209 RVA: 0x0009B770 File Offset: 0x00099970
		public void ClearStereoModel()
		{
			IntPtr proc = HalconAPI.PreCall(519);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Reconstruct 3D points from calibrated multi-view stereo images.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="row">Row coordinates of the detected points.</param>
		/// <param name="column">Column coordinates of the detected points.</param>
		/// <param name="covIP">Covariance matrices of the detected points. Default: []</param>
		/// <param name="cameraIdx">Indices of the observing cameras.</param>
		/// <param name="pointIdx">Indices of the observed world points.</param>
		/// <param name="x">X coordinates of the reconstructed 3D points.</param>
		/// <param name="y">Y coordinates of the reconstructed 3D points.</param>
		/// <param name="z">Z coordinates of the reconstructed 3D points.</param>
		/// <param name="covWP">Covariance matrices of the reconstructed 3D points.</param>
		/// <param name="pointIdxOut">Indices of the reconstructed 3D points.</param>
		// Token: 0x06001842 RID: 6210 RVA: 0x0009B7A4 File Offset: 0x000999A4
		public void ReconstructPointsStereo(HTuple row, HTuple column, HTuple covIP, int cameraIdx, int pointIdx, out HTuple x, out HTuple y, out HTuple z, out HTuple covWP, out HTuple pointIdxOut)
		{
			IntPtr proc = HalconAPI.PreCall(520);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, row);
			HalconAPI.Store(proc, 2, column);
			HalconAPI.Store(proc, 3, covIP);
			HalconAPI.StoreI(proc, 4, cameraIdx);
			HalconAPI.StoreI(proc, 5, pointIdx);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			HalconAPI.InitOCT(proc, 4);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(row);
			HalconAPI.UnpinTuple(column);
			HalconAPI.UnpinTuple(covIP);
			num = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, num, out x);
			num = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, num, out y);
			num = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, num, out z);
			num = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, num, out covWP);
			num = HTuple.LoadNew(proc, 4, HTupleType.INTEGER, num, out pointIdxOut);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Reconstruct 3D points from calibrated multi-view stereo images.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="row">Row coordinates of the detected points.</param>
		/// <param name="column">Column coordinates of the detected points.</param>
		/// <param name="covIP">Covariance matrices of the detected points. Default: []</param>
		/// <param name="cameraIdx">Indices of the observing cameras.</param>
		/// <param name="pointIdx">Indices of the observed world points.</param>
		/// <param name="x">X coordinates of the reconstructed 3D points.</param>
		/// <param name="y">Y coordinates of the reconstructed 3D points.</param>
		/// <param name="z">Z coordinates of the reconstructed 3D points.</param>
		/// <param name="covWP">Covariance matrices of the reconstructed 3D points.</param>
		/// <param name="pointIdxOut">Indices of the reconstructed 3D points.</param>
		// Token: 0x06001843 RID: 6211 RVA: 0x0009B878 File Offset: 0x00099A78
		public void ReconstructPointsStereo(double row, double column, HTuple covIP, int cameraIdx, int pointIdx, out double x, out double y, out double z, out double covWP, out int pointIdxOut)
		{
			IntPtr proc = HalconAPI.PreCall(520);
			base.Store(proc, 0);
			HalconAPI.StoreD(proc, 1, row);
			HalconAPI.StoreD(proc, 2, column);
			HalconAPI.Store(proc, 3, covIP);
			HalconAPI.StoreI(proc, 4, cameraIdx);
			HalconAPI.StoreI(proc, 5, pointIdx);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			HalconAPI.InitOCT(proc, 4);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(covIP);
			num = HalconAPI.LoadD(proc, 0, num, out x);
			num = HalconAPI.LoadD(proc, 1, num, out y);
			num = HalconAPI.LoadD(proc, 2, num, out z);
			num = HalconAPI.LoadD(proc, 3, num, out covWP);
			num = HalconAPI.LoadI(proc, 4, num, out pointIdxOut);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Reconstruct surface from calibrated multi-view stereo images.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="images">An image array acquired by the camera setup associated with the stereo model.</param>
		/// <returns>Handle to the resulting surface.</returns>
		// Token: 0x06001844 RID: 6212 RVA: 0x0009B93C File Offset: 0x00099B3C
		public HObjectModel3D ReconstructSurfaceStereo(HImage images)
		{
			IntPtr proc = HalconAPI.PreCall(521);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, images);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HObjectModel3D result;
			num = HObjectModel3D.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(images);
			return result;
		}

		/// <summary>
		///   Get intermediate iconic results of a stereo reconstruction.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="pairIndex">Camera indices of the pair ([From, To]).</param>
		/// <param name="objectName">Name of the iconic result to be returned.</param>
		/// <returns>Iconic result.</returns>
		// Token: 0x06001845 RID: 6213 RVA: 0x0009B994 File Offset: 0x00099B94
		public HObject GetStereoModelObject(HTuple pairIndex, string objectName)
		{
			IntPtr proc = HalconAPI.PreCall(522);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, pairIndex);
			HalconAPI.StoreS(proc, 2, objectName);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(pairIndex);
			HObject result;
			num = HObject.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get intermediate iconic results of a stereo reconstruction.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="pairIndex">Camera indices of the pair ([From, To]).</param>
		/// <param name="objectName">Name of the iconic result to be returned.</param>
		/// <returns>Iconic result.</returns>
		// Token: 0x06001846 RID: 6214 RVA: 0x0009B9F4 File Offset: 0x00099BF4
		public HObject GetStereoModelObject(int pairIndex, string objectName)
		{
			IntPtr proc = HalconAPI.PreCall(522);
			base.Store(proc, 0);
			HalconAPI.StoreI(proc, 1, pairIndex);
			HalconAPI.StoreS(proc, 2, objectName);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HObject result;
			num = HObject.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Return the list of image pairs set in a stereo model.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="to">Camera indices for the to cameras in the image pairs.</param>
		/// <returns>Camera indices for the from cameras in the image pairs.</returns>
		// Token: 0x06001847 RID: 6215 RVA: 0x0009BA4C File Offset: 0x00099C4C
		public HTuple GetStereoModelImagePairs(out HTuple to)
		{
			IntPtr proc = HalconAPI.PreCall(523);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, HTupleType.INTEGER, num, out result);
			num = HTuple.LoadNew(proc, 1, HTupleType.INTEGER, num, out to);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Specify image pairs to be used for surface stereo reconstruction.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="from">Camera indices for the from cameras in the image pairs.</param>
		/// <param name="to">Camera indices for the to cameras in the  image pairs.</param>
		// Token: 0x06001848 RID: 6216 RVA: 0x0009BAA8 File Offset: 0x00099CA8
		public void SetStereoModelImagePairs(HTuple from, HTuple to)
		{
			IntPtr proc = HalconAPI.PreCall(524);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, from);
			HalconAPI.Store(proc, 2, to);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(from);
			HalconAPI.UnpinTuple(to);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Get stereo model parameters.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="genParamName">Names of the parameters to be set.</param>
		/// <returns>Values of the parameters to be set.</returns>
		// Token: 0x06001849 RID: 6217 RVA: 0x0009BAF8 File Offset: 0x00099CF8
		public HTuple GetStereoModelParam(HTuple genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(525);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get stereo model parameters.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="genParamName">Names of the parameters to be set.</param>
		/// <returns>Values of the parameters to be set.</returns>
		// Token: 0x0600184A RID: 6218 RVA: 0x0009BB50 File Offset: 0x00099D50
		public HTuple GetStereoModelParam(string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(525);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Set stereo model parameters.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="genParamName">Names of the parameters to be set.</param>
		/// <param name="genParamValue">Values of the parameters to be set.</param>
		// Token: 0x0600184B RID: 6219 RVA: 0x0009BBA0 File Offset: 0x00099DA0
		public void SetStereoModelParam(HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(526);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set stereo model parameters.
		///   Instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="genParamName">Names of the parameters to be set.</param>
		/// <param name="genParamValue">Values of the parameters to be set.</param>
		// Token: 0x0600184C RID: 6220 RVA: 0x0009BBF0 File Offset: 0x00099DF0
		public void SetStereoModelParam(string genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(526);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a HALCON stereo model.
		///   Modified instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="cameraSetupModelID">Handle to the camera setup model.</param>
		/// <param name="method">Reconstruction method. Default: "surface_pairwise"</param>
		/// <param name="genParamName">Name of the model parameter to be set. Default: []</param>
		/// <param name="genParamValue">Value of the model parameter to be set. Default: []</param>
		// Token: 0x0600184D RID: 6221 RVA: 0x0009BC3C File Offset: 0x00099E3C
		public void CreateStereoModel(HCameraSetupModel cameraSetupModelID, string method, HTuple genParamName, HTuple genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(527);
			HalconAPI.Store(proc, 0, cameraSetupModelID);
			HalconAPI.StoreS(proc, 1, method);
			HalconAPI.Store(proc, 2, genParamName);
			HalconAPI.Store(proc, 3, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(cameraSetupModelID);
		}

		/// <summary>
		///   Create a HALCON stereo model.
		///   Modified instance represents: Handle of the stereo model.
		/// </summary>
		/// <param name="cameraSetupModelID">Handle to the camera setup model.</param>
		/// <param name="method">Reconstruction method. Default: "surface_pairwise"</param>
		/// <param name="genParamName">Name of the model parameter to be set. Default: []</param>
		/// <param name="genParamValue">Value of the model parameter to be set. Default: []</param>
		// Token: 0x0600184E RID: 6222 RVA: 0x0009BCB4 File Offset: 0x00099EB4
		public void CreateStereoModel(HCameraSetupModel cameraSetupModelID, string method, string genParamName, HTuple genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(527);
			HalconAPI.Store(proc, 0, cameraSetupModelID);
			HalconAPI.StoreS(proc, 1, method);
			HalconAPI.StoreS(proc, 2, genParamName);
			HalconAPI.Store(proc, 3, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(cameraSetupModelID);
		}

		/// <summary>
		///   Get intermediate 3D object model of a stereo reconstruction
		///   Instance represents: Handle des Stereomodells.
		/// </summary>
		/// <param name="genParamName">Namen der Modellparameter.</param>
		/// <returns>Werte der Modellparameter.</returns>
		// Token: 0x0600184F RID: 6223 RVA: 0x0009BD28 File Offset: 0x00099F28
		public HObjectModel3D GetStereoModelObjectModel3d(HTuple genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(2074);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HObjectModel3D result;
			num = HObjectModel3D.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get intermediate 3D object model of a stereo reconstruction
		///   Instance represents: Handle des Stereomodells.
		/// </summary>
		/// <param name="genParamName">Namen der Modellparameter.</param>
		/// <returns>Werte der Modellparameter.</returns>
		// Token: 0x06001850 RID: 6224 RVA: 0x0009BD80 File Offset: 0x00099F80
		public HObjectModel3D GetStereoModelObjectModel3d(string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(2074);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HObjectModel3D result;
			num = HObjectModel3D.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}
	}
}
